export default function nextTokens(tokens){
    var sections = [];
    var res = [];
    //收集器指向res，引用类型指向同一个数组
    var collector = res;
    for (let i = 0; i < tokens.length; i++) {
        let token = tokens[i];
        // console.log(token);
        switch (token[0]){
            case'#':
                //收集子元素
                collector.push(token);
                sections.push(token);
                //存放子数组
                token[2] = [];
                collector = token[2];
                break;
            case '/':
                let section=sections.pop();
                //将收集器指回栈顶的数组
                //考虑栈为空的情况
                collector = sections.length > 0? sections[sections.length-1][2]:res;
                break;
            default:
                collector.push(token)
        }
        
    }
    return res;
}